package com.augurit.common.system.service.org;

import java.util.List;

import org.springside.modules.orm.Page;

import com.augurit.common.base.service.IBaseService;
import com.augurit.common.system.web.auth.form.LoginUserForm;
import com.augurit.common.system.web.org.form.AcMenuForm;
import com.augurit.common.system.web.org.form.AtHomepageConfigForm;


/**
 * 菜单接口
 */
public interface IAcMenuService extends IBaseService<AcMenuForm, Long>{
	
	public void saveCascade(AcMenuForm... forms);
	
	public AcMenuForm get(Long id);
	
	public List getMenusByMenuLevel(LoginUserForm loginUser, AtHomepageConfigForm atHomepageConfigForm);
	
	public List getMenusByMenuLevel(int loadMenuLevel, String loadByTree, String modelName);

	public List<AcMenuForm> getMenusByMenuLevel(LoginUserForm loginUser, int loadMenuLevel, String loadByTree);
	
	public List getMenusByMenuLevel(LoginUserForm loginUser, int loadMenuLevel, String loadByTree, String modelName, boolean onlyActiveMenu);
	
	public List getChildTree(Long parentMenuId, String modelName);
	
	public List<AcMenuForm> getChildTree(LoginUserForm loginUser, Long parentMenuId, int depth);
	
	public List getChildTree(LoginUserForm loginUser, Long parentMenuId, int depth, String modelName, boolean onlyActiveMenu);
	
	/**
	 * 根据功能ID集合获取关联的菜单ID集合
	 * 注意：如果某菜单存在父菜单，则同时也会返回其所有关联的父菜单列表
	 * @param funcIds
	 * @return
	 */
	public Long[] getAllRelatedMenuIds(Long[] funcIds);
	
	/**
	 * 获取指定菜单对应的功能id
	 * @param menuId 菜单id 
	 * @return 功能id
	 */
	public Long getRelatedFuncIdByMenuId(Long menuId);
	
	/**
	 * 根据菜单对象主键ID获取菜单层次
	 * @param menuId 菜单对象主键ID
	 * @return 正整数的菜单层次，如为-1则表示指定菜单对象不存在或菜单属性为空。
	 */
	public int getMenuLevel(Long menuId);
	
	/**
	 * 给定一些菜单的id，分页查询在其中的菜单
	 * @param page 分页对象
	 * @param menuIds 菜单数组
	 * @return 分页对象
	 */
	public Page<AcMenuForm> getMenusInMenuIds(Page<AcMenuForm> page, Long[] menuIds);
	
	/**
	 * 给定一些菜单的id,获取（非叶子）菜单列表
	 * @param menuIds
	 * @return
	 */
	public List<AcMenuForm> getMenusInMenuIds(Long[] menuIds);
	/**
	 * 给定一些菜单的id，分页查询不在其中的菜单
	 * @param page 分页对象
	 * @param menuIds 菜单数组
	 * @return 分页对象
	 */
	public Page<AcMenuForm> getMenusNotInMenuIds(Page<AcMenuForm> page, Long[] menuIds);
	
	public Page<AcMenuForm> getAllMenus(Page<AcMenuForm> page);
	
	/**
	 * 获取系统中所有与功能点关联的菜单
	 * @param page 分页对象
	 * @param form f
	 * @return
	 */
	public Page<AcMenuForm> getAllMenusAssociateFunc(Page<AcMenuForm> page, AcMenuForm form);
	
	public Page<AcMenuForm> getAllMenus(Page<AcMenuForm> page, AcMenuForm form);
	
	public List<AcMenuForm> searchMenu(LoginUserForm loginUser, AcMenuForm form);
	
	/**
	 * 级联删除菜单
	 * @param menuId
	 */
	public void deleteMenuCasCade(Long menuId);
	
	/**
	 * 级联删除菜单
	 * @param menuIds
	 */
	public void deleteMenuCasCade(Long... menuIds);
	
	/**
	 * 获取用户具有权限的菜单id数组
	 * @param userId
	 * @return 菜单id数组
	 */
	public Long[] getMenuIdsOwnedByUser(Long userId);
}
